Skip to content

Use attributes for native module and functions #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

lht
Copy link
Contributor

@lht lht commented Nov 15, 2011

Hi,

Commits of this branch fix issue #547 and #906.

I used the intermittent commit b033f8a2cf8d1025f2bb85fc284f5b72f1ec27de as a transitional commit. Tested by build b033f8a2cf8d1025f2bb85fc284f5b72f1ec27de first, and copied stage3 as stage0 and build bf612bf.

Similar change of crate directive will be ready in another commit in a few days.

Haitao

@lht
Copy link
Contributor Author

lht commented Nov 15, 2011

And should have updated the FFI section of the tutorial.

@brson
Copy link
Contributor

brson commented Nov 15, 2011

It looks like this series leaves the native_name and abi in the AST, and the parser just immediately interprets the attributes. I would like to eliminate this duplication - things that are attributes should be metadata about the AST, not part of the AST itself.

Removing the native ABI from the AST looks involved (because the ABI is part of the function type), and we're probably going to want to make some changes to how native functions are handled before we take it out (specifically, make it not part of the function type), but I think we can remove native_name from the AST.

Can you remove native_name and just have any code that cares look it up in the attribute list (as link_name), and then add a FIXME to the abi field of ast::native_mod referencing issue 1179?

lht added 4 commits November 16, 2011 23:45
This patch adds support of using attributes to specify native mode ABI
and link name. The old optional syntax like:
  native "cdecl" mod llvm = "rustllvm" { ... }
is still supported.

This is a transitional commit to avoid making a stage1 (backward
imcompatible) snapshot.
This patch changes how to specify ABI and link name of a native module.

Before:
  native "cdecl" mod llvm = "rustllvm" {...}

After:
  #[abi = "cdecl"]
  #[link_name = "rustllvm"]
  native mod llvm {...}

The old optional syntax for ABI and link name is no longer supported.

Fixes issue rust-lang#547
@lht
Copy link
Contributor Author

lht commented Nov 16, 2011

Thanks for the comments! They are very valid points. I have removed consumption of attributes in parser (except for the ABI attribute) and chopped unnecessary fields of AST.

@brson
Copy link
Contributor

brson commented Nov 16, 2011

Thanks! Integrated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants